<?php
/**
 * Created by PhpStorm.
 * Email: 1194008361@qq.com
 * User:liaosp.top
 * Date: 2018/9/8
 * Time: 15:15
 */
function config($key,$default = null)
{
    $config = require THINKSP . '/config/app.php';
    if (empty($key)) {
        return $config;
    }
    $data = @$config[$key];
    if (empty($data)) {
        return $default;
    } else {
        return $data;
    }
}


function cache($name, $data = array(), $extime = 0)
{
  return \core\lib\cache\Cache::cache($name,$data,$extime);
}
function error($msg ='error',$code =403,$option =''){
    $data =[
        'msg'=>$msg,
        'code'=>$code,
        'option'=>$option
    ];
    echo json_encode($data);
}
function success($msg ='error',$result=[],$code =200,$option =''){

    $data =[
        'msg'=>$msg,
        'result'=>$result,
        'code'=>$code,
        'option'=>$option
    ];
    echo json_encode($data);
}

